package com.duan.laugh.common.security.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 没有资源的访问权限
 *
 * @author duanjw
 */
@Slf4j
public class LaughAccessDeniedHandler implements AccessDeniedHandler {

    public static final String MESSAGE = "没有访问权限";

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) {
        HttpUtil.write(request, response, MESSAGE);
    }
}
